<template>
  <div style="padding: 20px">
    <el-card>
      <div slot="header">个人会员日志</div>
      <el-row :gutter="10" type="flex" style="margin-top: 20px" justify="start">
        <el-form ref="form" :model="form" label-width="80px" class="el-form">
          <el-form-item label="会员uid:">
            <el-input
              clearable
              v-model.number="personLogQuery.uid"
              @keyup.enter.native="searchClick"
              placeholder="请输入会员uid"
            ></el-input>
          </el-form-item>
          <el-form-item label="关键字:">
            <el-input
              clearable
              v-model="personLogQuery.keyword"
              @keyup.enter.native="searchClick"
              placeholder="请输入关键字"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="searchClick">查询</el-button>
          </el-form-item>
        </el-form>
      </el-row>
      <el-table :data="personLogList" style="width: 100%" max-height="600px">
        <el-table-column prop="uid" label="UID" align="center" width="width">
        </el-table-column>
        <el-table-column
          prop="addtime"
          label="时间"
          width="width"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.addtime | dateFormat }}
          </template>
        </el-table-column>
        <el-table-column
          prop="content"
          label="操作"
          width="width"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="companyName"
          label="姓名"
          width="width"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="ip"
          label="IP"
          width="width"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="ipAddr"
          label="IP归属地"
          width="width"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="platform"
          label="来源"
          width="width"
          align="center"
        >
        </el-table-column>
      </el-table>
      <el-row :gutter="10" style="margin-top: 20px" type="flex" justify="end">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="personLogQuery.page"
          :page-sizes="[10, 20, 30,50]"
          :page-size="personLogQuery.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { selPersonLogApi } from "@/api/system";
export default {
  data() {
    return {
      manage: [
        { id: 1, name: "全部" },
        { id: 2, name: "sys" },
        { id: 3, name: "blrc" },
        { id: 4, name: "blrcfwzx" },
        { id: 5, name: "lunchuan" },
        { id: 6, name: "admin" },
      ],
      personLogQuery: {
        page: 1,
        pageSize: 10,
        uid: null,
        keyword: "",
      },
      total: "",
      personLogList: [],
    };
  },
  created() {
    this.selPersonLog();
  },
  methods: {
    // 查询
    searchClick() {
      this.selPersonLog();
    },
    // 改变页数
    handleSizeChange(pageSize) {
      this.personLogQuery.pageSize = pageSize;
      this.selPersonLog();
    },
    // 点击当前页数
    handleCurrentChange(page) {
      this.personLogQuery.page = page;
      this.selPersonLog();
    },
    async selPersonLog() {
      const res = await selPersonLogApi(this.personLogQuery);
      console.log(res);
      this.personLogList = res.records;
      this.total = res.total;
    },
  },
};
</script>

<style lang="scss" scoped>
.el-form {
  display: flex;
}
</style>
